from typing import Dict


class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def say(self) -> None:
        print(f'{self.name} is {self.age} years old')

    def work(self) -> int:
        print(f'{self.name} is working')
        return 10

    def friend(self, target_name: str, age: int) -> None:
        print(f'{self.name} is {target_name} friend')

    def children(self, *args):
        '''
        入参中args中带有 * 号，标识会在调用函数的时候会自动封包
        一个方法同时返回多个值，会将这些字自动封包成一个Tuple进行返回，所以这里如果需要定义返回值，那么他的返回值是Tuple
        :param kwargs:
        :return:
        '''
        for arg in args:
            print(arg)
        print(f'{self.name} is children')
        return '孩子1', '孩子2', '孩子3', '孩子4'

    def stu(self, **kwargs) -> Dict[str, str]:
        '''
        这里**kwargs 表示会直接将数据封包成字典
        :param kwargs: math 数学， chinese 汉语 ，python 爬虫
        :return: 封装的dict数据
        '''
        r = {"name": self.name, "age": self.age}
        for subject, secore in kwargs.items():
            print(f'{subject} is {secore}')
            r.update({subject: secore})
        return r


p = Person('张白龟', 10)
p.say()
p.work()
p.friend('徐阶', 100)
print('-' * 30)

# 封包
data = 1, 2, 3, 4
print(data)

# 解包
a, b, c, d = data
print(f'{a} + {b} = {c} + {d}')
children = p.children('1', '2', '3')
# children[0]='这里不允许修改，这是元祖类型'

print('-' * 30)

r = p.stu(math=40, chinese=50, python=90)
print(r, type(r), isinstance(r, dict))

print('-' * 15, "04 万物皆对象，包括函数", '-' * 15)

print(p.stu)
print(p.stu(math=20))
# 直接将方法全局化
func = p.stu
print(func(math=20))
# 直接将方法全局化
p2 = Person('高拱', 30)
func2 = p2.stu
print(func2(math=20))


def merge_dict(var1: dict, var2: dict, repeatHandler: str, **kwargs) -> dict:
    '''

    :param kwargs:
    :return:
    '''
